package com.palm.hubo2o.ui;

import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.palm.hubo2o.BaseActivity;
import com.palm.hubo2o.R;
import com.palm.hubo2o.model.User;
import com.palm.hubo2o.network.PalmSession;
import com.palm.hubo2o.util.PromptUtil;
import com.palm.palmutils.StringUtils;
import com.palm.palmutils.widget.CellView;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class UserInfoActivity extends BaseActivity {

    @Bind(R.id.userinfo_realname)
    CellView realNameCellView;
    @Bind(R.id.userinfo_bank)
    CellView bankCellView;
    @Bind(R.id.userinfo_station)
    CellView stationCellView;
    @Bind(R.id.userinfo_phone_rl)
    RelativeLayout phoneRL;
    @Bind(R.id.userinfo_phone_tv)
    TextView phoneTV;
    @Bind(R.id.userinfo_phone_modify_btn)
    TextView phoneModifyBtn;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_user_info);
        ButterKnife.bind(this);

        User user = PalmSession.getGlobal();
        if(user!=null){
            if(phoneTV!=null)phoneTV.setText(user.getMobile());
            if(phoneModifyBtn!=null)phoneModifyBtn.setVisibility(View.VISIBLE);
            if(realNameCellView!=null)realNameCellView.setDesc(StringUtils.isEmpty(user.getRealName())?R.string.userinfo_realname_info_no:R.string.userinfo_realname_info_yes);
            if(bankCellView!=null)bankCellView.setDesc(StringUtils.isEmpty(user.getCardNo())?R.string.userinfo_bank_info_no:R.string.userinfo_bank_info_yes);

        }
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (android.R.id.home == item.getItemId()) {
            finish();
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    @OnClick({R.id.userinfo_realname,R.id.userinfo_bank,R.id.userinfo_phone_modify_btn,R.id.userinfo_station})
    public void OnClick(View v){
        switch (v.getId()){
            case R.id.userinfo_realname:
                PromptUtil.showToast(UserInfoActivity.this,"realname");
                break;
            case R.id.userinfo_bank:
                PromptUtil.showToast(UserInfoActivity.this,"bank");
                break;
            case R.id.userinfo_phone_modify_btn:
                PromptUtil.showToast(UserInfoActivity.this,"modify");
                break;
            case R.id.userinfo_station:
                PromptUtil.showToast(UserInfoActivity.this,"station");
                break;
        }
    }


}
